
#include "test_case.hpp"

/*
g++ test_case.cpp -static -I../insdir/include -L../insdir/lib -lboost_system -lpthread -lboost_coroutine -lboost_context
*/

int test_case0_p11_boost_version(void) {
    using namespace std;

    cout << BOOST_VERSION << endl;
    cout << BOOST_LIB_VERSION << endl;
    cout << BOOST_PLATFORM << endl;
    cout << BOOST_COMPILER << endl;
    //cout << BOOST_STDLIB << endl;
    std::printf("helloworld\n");
    return 0;
}

int test_case1_coroutine2() {

    boost::coroutines2::coroutine< int >::pull_type source(
        []( boost::coroutines2::coroutine< int >::push_type & sink) {
            int first = 1, second = 1;
            sink( first);
            sink( second);
            for ( int i = 0; i < 8; ++i) {
                int third = first + second;
                first = second;
                second = third;
                sink( third);
            }
        });
    for ( auto i : source) {
        std::cout << i <<  " ";
    }
    std::cout << "\nDone" << std::endl;
    return EXIT_SUCCESS;
}

void test_case2() {

  // 创建 I/O 上下文和定时器  
    boost::asio::io_context io;  
    boost::asio::deadline_timer timer(io, boost::posix_time::seconds(5));
  
    // 设置定时器完成时调用的处理程序  
    timer.async_wait([](const boost::system::error_code& /*e*/) {  
        std::cout << "Hello, World!" << std::endl;  
    });  
  
    // 运行 I/O 上下文以启动事件处理循环  
    io.run();  

    //原文链接：https://blog.csdn.net/h8062651/article/details/138044552

}

int main() {

    test_case0_p11_boost_version();
    //test_case1_coroutine2();
    test_case2();
    return 0;
}   